package com.jxm.comparable;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2022/6/9 9:16
 * @Version: 1.0
 */
public class Student implements Comparable<Student>{

    private String userName;
    private Integer age;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    //定义比较规则
    @Override
    public int compareTo(Student o) {
        return this.age - o.age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "userName='" + userName + '\'' +
                ", age=" + age +
                '}';
    }
}
